package cc.admin.common.db.table.entity;

import java.util.Collection;
import java.util.List;
/**
 * @author: ZhangHouYing
 * @date: 2021-08-21 19:04
 */
public class DbSql {

	private String sql;

	private List<Object> params;

	public DbSql() {
	}

	public DbSql(String sql) {
		this.sql = sql;
	}

	public DbSql(String sql, List<Object> params) {
		this.sql = sql;
		this.params = params;
	}

	public String getSql() {
		return sql;
	}

	public void setSql(String sql) {
		this.sql = sql;
	}

	public List<Object> getParams() {
		return params;
	}

	public void setParams(List<Object> params) {
		this.params = params;
	}

	public Object[] getParamArray() {
		if (isNullOrEmpty(params)) {
			return new Object[0];
		} else {
			return params.toArray(new Object[params.size()]);
		}
	}

	private static boolean isNullOrEmpty(Collection<?> c) {
		return c == null ? true : c.isEmpty();
	}
}
